<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //数组中所有的数字之和
    var arr=[1,2,3,4,5,6,7,8];
    var n=0; 
        for (var i=0;i<arr.length;i++){
            n+=arr[i];
        }
        console.log(n);
    //遍历数组将数组所有元素挨个打印
    console.log(arr[0])
     console.log(arr[1])
for(var i=0;i<arr.length;i++){
    console.log(arr[i])
}
while(i<arr.length){
    console.log(arr[i])
    i++;
}
//打印最大值
var a1=[1,1,3,4,5,67,89];
var s=0;
for (var i=0;i<a1.length;i++){
    if(s<a1[i]){
        n=a1[i];
    }
}
console.log(n);
//打印出数组中的所有偶数
var a2=[1,2,3,4,5,6,7,8];
for(var i=0;i<a1.length;i++){
    if(a2[i]%2==0){
        console.log(a2[i]);
    }
} 
//将数组中的元素以|分离为一个字符串
var a3=[12,34,26,24,46,32];
var l='';
for(var i=0;i<a3.length;i++){
    l+=a3[i]+'|';
}
console.log(l);
</script>
</html>